// https://nuxt.com/docs/api/configuration/nuxt-config
import { NaiveUiResolver } from 'unplugin-vue-components/resolvers'
import Components from 'unplugin-vue-components/vite'
import Icons from 'unplugin-icons/vite'
import IconsResolver from 'unplugin-icons/resolver'

export default defineNuxtConfig({
  devtools: { enabled: true },
  app: {
    head: {
      charset: 'utf-8',
      viewport: 'width=device-width',
      title: '夏目友人站',
      meta: [
        { name: 'description', content: '夏目友人站' }
      ],
    }
  },
  build: {
    transpile:
        process.env.NODE_ENV === 'production'
            ? [
              'naive-ui',
              'vueuc',
              '@css-render/vue3-ssr',
              '@juggle/resize-observer'
            ]
            : ['@juggle/resize-observer']
  },
  modules:[
    '@pinia/nuxt',
    '@pinia-plugin-persistedstate/nuxt',
    '@nuxtjs/device',
    // '@nuxtjs/i18n'
  ],
  // i18n: {
  //   // // lang type: https://www.naiveui.com/zh-CN/os-theme/docs/i18n
  //   // vueI18n: './i18n.config.ts',
  //   // Lazy-load translations: https://v8.i18n.nuxtjs.org/guide/lazy-load-translations
  //   locales: [
  //     {
  //       code: 'zh',
  //       iso: 'zh-CN',
  //       name: '中文',
  //       file: 'zh-CN.ts'
  //     },{
  //       code: 'en',
  //       iso: 'en-US',
  //       name: 'English',
  //       file: 'en-US.ts'
  //     },{
  //       code: 'ja',
  //       iso: 'ja-JP',
  //       name: 'わぶん',
  //       file: 'ja-JP.ts'
  //     }
  //   ],
  //   lazy: true,
  //   langDir: 'lang',
  //   defaultLocale: 'zh',
  //   experimental: {
  //     jsTsFormatResource: true
  //   }
  // },
  vite: {
    plugins: [
      Components({
        resolvers: [
          NaiveUiResolver(),
          IconsResolver({
            prefix:'i',
            enabledCollections:['ep', 'ant-design']
          })
        ]
      }),
      Icons({
        autoInstall: true
      })
    ],
    optimizeDeps: {
      include:
          process.env.NODE_ENV === 'development'
              ? ['naive-ui', 'vueuc', 'date-fns-tz/esm/formatInTimeZone']
              : []
    },
    ssr: {
      noExternal: ['naive-ui', '@juggle/resize-observer', '@css-render/vue3-ssr']
    },
    css: {
      preprocessorOptions: {
        scss: {
          additionalData: '@use "@/assets/_variables.scss" as *;'
        }
      }
    }
  }
})
